<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">

<!-- 可选的Bootstrap主题文件（一般不用引入） -->
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<title>Insert title here</title>
</head>
<body>
    <button id="findpass" value="待审核商家" >待审核商家</button><button id="findnotpass" value="已商家">已审核商家</button>
    <table id="stus" class="table table-striped  table-hover">
    	<tr><th>shopId</th><th>bossName</th><th>shopPhone</th><th>pass</th><th>notpass</th><th></th><th></th></tr>
    </table>
    

<script>
var stus=$("#stus");
$("#findnotpass").click(function(){
	$("#stus tr:not(first)").html("");
    $.ajax("queryShop12",{
        method:"GET",
        type:"json",
        success:function(d){
        	//alert(d.toString());
        	var item; 
        	$.each(d,function(i,result){ 
        		item = "<tr><td>"+result['shopId']+"</td><td>"+result['shopName']+"</td><td>"+result['bossName']+"</td><td>"+result['shopAddress']+"</td><td>"+result['status']+'</td><td><button onclick="deleteShop(this)">下架商家</button></td>+<td></td></tr>';
        	$('.table').append(item); 
        	}); 
        	
        }
    });
});


$("#findpass").click(function(){
	$("#stus tr:not(first)").html("");
    $.ajax("queryShop1",{
        method:"GET",
        type:"json",
        success:function(d){
        	//alert(d.toString());
        	var item; 
        	$.each(d,function(i,result){ 
        	item = "<tr><td>"+result['shopId']+"</td><td>"+result['shopName']+"</td><td>"+result['bossName']+"</td><td>"+result['shopAddress']+"</td><td>"+result['credit']+'</td><td><button onclick="pass(this)">通过</button></td>+</td><td><button onclick="checkNotPass(this)">拒绝</button></td></tr>'; 
        	$('.table').append(item); 
        	}); 
        	
        }
    });
});



//var pass=function(btn){
	function pass(btn){
    var tr = btn.parentElement.parentElement;
    var td = tr.cells[0]; 
    var id = td.innerHTML;
    $(td).parent().remove(); 
    //tr.remove();
    var data={shopId:id};
    alert("商家入驻成功！");
    $.ajax("checkPass",{
        method:"post",
        //contentType:"application/json",
        type:"json",
        data:data
        });
}
   
	function checkNotPass(btn){
	    var tr = btn.parentElement.parentElement;
	    var td = tr.cells[0]; 
	    var id = td.innerHTML;
	    $(td).parent().remove(); 
	    //tr.remove();
	    var data={shopId:id};
	    alert("拒绝商家入驻");
	    $.ajax("checkNotPass",{
	        method:"post",
	        //contentType:"application/json",
	        type:"json",
	        data:data
	        });
	} 
	function deleteShop(btn){
	    var tr = btn.parentElement.parentElement;
	    var td = tr.cells[0]; 
	    var id = td.innerHTML;
	    $(td).parent().remove(); 
	    //tr.remove();
	    var data={shopId:id};
	    alert("下架商家成功");
	    $.ajax("checkNotPass",{
	        method:"post",
	        //contentType:"application/json",
	        type:"json",
	        data:data
	        });
	}
	
	
	
	
	
	
    //var r=td.children[0].value;
    
   /* $.ajax("checkPass",{
        method:"POST",
        type:"json",
        success:function(){
        	
        	}); 
        	
        }
    });*/
    //var txt = document.createElement("input");
    //txt.type="text";
    //txt.value = td.innerHTML;
    //td.innerHTML = "";
    //td.appendChild(txt);
//}


</script>
    
</body>
</html>